<%@ include file="../common/IncludeTop.jsp"%>
<script type="text/javascript" src="/JS/jquery-3.5.1.js"></script>
<script>
	let xhr;
	function checkUsername(){
		let username = document.getElementById('username').value;
		xhr = new XMLHttpRequest();
		xhr.onreadystatechange = process;
		xhr.open("GET", "usernameIsExist?username = "+username, true);
		xhr.send(null);
	}
	function process(){
		if(xhr.readyState == 4){
			if(xhr.status == 200){
				let responseInfo = xhr.responseText;
				let msg = document.getElementById('isExistInfo');
				if(responseInfo == 'Exist'){
					msg.classList.add('okmsg');
					msg.innerText = '用户名可用';
				}else if(responseInfo == 'Not Exist'){
					msg.classList.add('errormsg');
					msg.innerText = '用户名不可用';
				}
			}
		}
	}
</script>
<div id="Catalog"><form action="signon" method="post">

	<p>Please enter your username and password.</p>
	<p>Username: <label><input type="text" name="username" value="${sessionScope.username}"/>
	</label>
		<br>Password: <label><input type="password" name="password" value="${sessionScope.password}"/></label></p>

		<%@include file="../common/CheckCode.jsp"%>

	<br><br><font color="red">
		${requestScope.error1}
	</font><br>
	<input type="submit" value="Login" />
</form> Need a user name and password?
	<a href="register">Register Now!</a>
</div>

<%@ include file="../common/IncludeBottom.jsp"%>

